<template>
    <div class="common-layout">
      <el-container
      :default-active="$route.path"
      router>
       <el-header>
        <div>
          <el-menu
    :default-active="$route.path"
    router
    class="el-menu-demo"
    mode="horizontal"
    :ellipsis="false"
    @select="handleSelect"
  >
    <el-menu-item index="zuye">   首页   </el-menu-item>
    <el-sub-menu index="2">
      <template #title>运用场景</template>
      <el-menu-item v-for="(item,i) in navList1" :key="i" :index="item.path">
              {{item.name}}
            </el-menu-item>
    </el-sub-menu>
    <el-menu-item index="3" >分析报告</el-menu-item>
    <el-menu-item index="4">支付情况</el-menu-item>
    <el-menu-item index="5">系统管理</el-menu-item>
    <el-menu-item index="/">   退出   </el-menu-item>
    
    <el-menu-item index="3" class="a" >欢迎</el-menu-item>
    
  </el-menu>
        </div>
          
        <!--   <div class="flex flex-wrap items-center gap-4">
      <el-dropdown placement="top-start">
        <el-button @click="handleClick"> 首页 </el-button>
        <template #dropdown>
        </template>
      </el-dropdown>



      <el-dropdown placement="top">
        <el-button> 运用场景 </el-button>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item v-for="(item,i) in navList2" :key="i" :index="item.path">
              {{item.name}}
            </el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
      <el-dropdown placement="top-end">
        <el-button> 分析报告 </el-button>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>The Action 1st</el-dropdown-item>
            <el-dropdown-item>The Action 2st</el-dropdown-item>
            <el-dropdown-item>The Action 3st</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
      <el-dropdown placement="bottom-start">
        <el-button> 支付情况 </el-button>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>The Action 1st</el-dropdown-item>
            <el-dropdown-item>The Action 2st</el-dropdown-item>
            <el-dropdown-item>The Action 3st</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
      <el-dropdown placement="bottom">
        <el-button> 系统管理 </el-button>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>The Action 1st</el-dropdown-item>
            <el-dropdown-item>The Action 2st</el-dropdown-item>
            <el-dropdown-item>The Action 3st</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
      <el-dropdown placement="bottom-end">
        <el-button @click="handleClick2"> 退出 </el-button>
        <template #dropdown>
        </template>
      </el-dropdown>
    </div>-->
        </el-header>

        <el-container>
          <el-aside width="200px">
            
    
      <h5 class="mb-2">菜单栏</h5>
      <el-menu
        
        :default-active="$route.path"
        router
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        
      >
        <el-sub-menu index="1">
          <template #title>
            
          <el-icon><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" data-v-394d1fd8=""><path fill="currentColor" d="M160 448a32 32 0 0 1-32-32V160.064a32 32 0 0 1 32-32h256a32 32 0 0 1 32 32V416a32 32 0 0 1-32 32H160zm448 0a32 32 0 0 1-32-32V160.064a32 32 0 0 1 32-32h255.936a32 32 0 0 1 32 32V416a32 32 0 0 1-32 32H608zM160 896a32 32 0 0 1-32-32V608a32 32 0 0 1 32-32h256a32 32 0 0 1 32 32v256a32 32 0 0 1-32 32H160zm448 0a32 32 0 0 1-32-32V608a32 32 0 0 1 32-32h255.936a32 32 0 0 1 32 32v256a32 32 0 0 1-32 32H608z"></path></svg></el-icon>
                  

            <span>运用场景</span>
          </template>
            <el-menu-item v-for="(item,i) in navList" :key="i" :index="item.path">
              {{item.name}}
            </el-menu-item>
            
          </el-sub-menu>
        <el-menu-item index="2">
          <el-icon><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" data-v-394d1fd8=""><path fill="currentColor" d="M160 448a32 32 0 0 1-32-32V160.064a32 32 0 0 1 32-32h256a32 32 0 0 1 32 32V416a32 32 0 0 1-32 32H160zm448 0a32 32 0 0 1-32-32V160.064a32 32 0 0 1 32-32h255.936a32 32 0 0 1 32 32V416a32 32 0 0 1-32 32H608zM160 896a32 32 0 0 1-32-32V608a32 32 0 0 1 32-32h256a32 32 0 0 1 32 32v256a32 32 0 0 1-32 32H160zm448 0a32 32 0 0 1-32-32V608a32 32 0 0 1 32-32h255.936a32 32 0 0 1 32 32v256a32 32 0 0 1-32 32H608z"></path></svg></el-icon>
          <span>分析报告</span>
        </el-menu-item>
        <el-menu-item index="3" >
          <el-icon><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" data-v-394d1fd8=""><path fill="currentColor" d="M160 448a32 32 0 0 1-32-32V160.064a32 32 0 0 1 32-32h256a32 32 0 0 1 32 32V416a32 32 0 0 1-32 32H160zm448 0a32 32 0 0 1-32-32V160.064a32 32 0 0 1 32-32h255.936a32 32 0 0 1 32 32V416a32 32 0 0 1-32 32H608zM160 896a32 32 0 0 1-32-32V608a32 32 0 0 1 32-32h256a32 32 0 0 1 32 32v256a32 32 0 0 1-32 32H160zm448 0a32 32 0 0 1-32-32V608a32 32 0 0 1 32-32h255.936a32 32 0 0 1 32 32v256a32 32 0 0 1-32 32H608z"></path></svg></el-icon>
          <span>支付情况</span>
        </el-menu-item>
        <el-menu-item index="4">
          <el-icon><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" data-v-394d1fd8=""><path fill="currentColor" d="M160 448a32 32 0 0 1-32-32V160.064a32 32 0 0 1 32-32h256a32 32 0 0 1 32 32V416a32 32 0 0 1-32 32H160zm448 0a32 32 0 0 1-32-32V160.064a32 32 0 0 1 32-32h255.936a32 32 0 0 1 32 32V416a32 32 0 0 1-32 32H608zM160 896a32 32 0 0 1-32-32V608a32 32 0 0 1 32-32h256a32 32 0 0 1 32 32v256a32 32 0 0 1-32 32H160zm448 0a32 32 0 0 1-32-32V608a32 32 0 0 1 32-32h255.936a32 32 0 0 1 32 32v256a32 32 0 0 1-32 32H608z"></path></svg></el-icon>
          <span>系统管理</span>
        </el-menu-item>
      </el-menu>
    
 
          </el-aside>
          <el-main>
            <!--用路由占位才能显示-->
            <router-view></router-view>
          </el-main>
      </el-container>
    </el-container>
       

    </div>
  </template>


<script lang="ts">
import router from '@/router';
import {Document,Menu as IconMenu,Location,Setting} from '@element-plus/icons-vue'
import {reactive} from 'vue'
import { useRoute } from 'vue-router'
import user from '@/components/caidan/user.vue';

export default {
    setup() {
      const route = useRoute()
        const handleClick = () => {
            console.log('clicked')
            router.push('/zuye')
        }
        const handleClick2 = () => {
            console.log('clicked2')
            router.push('/')
        }
        const handleOpen = (key: string, keyPath: string[]) => {
          console.log(key, keyPath)
      }
        const handleClose = (key: string, keyPath: string[]) => {
          console.log(key, keyPath)
      }
      const handleSelect = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
        const navList = reactive ([
            {name:'用户管理',path:'/user'},
            {name:'角色管理',path:'/user2'},
            {name:'权限管理',path:'/user3'},
            {name:'菜单管理',path:'/user4'},
    ])
    const navList1 = reactive ([
            {name:'用户管理',path:'/user'},
            {name:'角色管理',path:'/user2'},
            {name:'权限管理',path:'/user3'},
            {name:'菜单管理',path:'/user4'},
    ])

        return {
            handleClick,
            handleClick2,
            handleOpen,
            handleClose,
            navList,
            navList1,
            handleSelect,
            
        }
    }
}

</script>  

<style scoped>
.common-layout {
height: 60px;
padding: 14px 60px;
background-color: #f0f2f5;

}
.el-col-12 {
  flex: 0 0 20%;
  
}
h5{
  font-size: 24px;
  text-align: center;
}
span{
  font-size: 18px;
}
/**第6个之后放在右边 */
.el-menu--horizontal > .el-menu-item:nth-child(6) {
  margin-right: auto;
}

</style>